const Controller = require('egg').Controller;

class Area extends Controller{
    async createArea(){
        const service = this.ctx.service.table.areaservice;
        const param = this.ctx.request.body.region;
        const result = await service.areaInsert(param);
        if(result){
            this.ctx.code = 200;
            this.ctx.body = 'success';
        }else{
            this.ctx.code = 300;
            this.ctx.body = result;
        }
    }
    async getAreaList(){
        const service = this.ctx.service.table.areaservice;
        const result = await service.getAreaList();
        if(result){
            this.ctx.code = 200;
            this.ctx.body=result;
        }else{
            this.ctx.code=300;
            this.ctx.body = 'error';
        }
    }
    async deleteArea(){
        const service = this.ctx.service.table.areaservice;
        const param = this.ctx.request.body.id;
        const result = await service.deleteArea(param);
        this.ctx.code = 200;
        this.ctx.body = 'success';
    }
}

module.exports = Area;
